package sliver.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import sliver.dao.AdvertiserDao;
import sliver.entity.Advertiser;

@Repository
public class AdvertiserDaoImpl extends BaseDaoImpl<Advertiser> implements AdvertiserDao{

	@Override
	public Advertiser findByAuth(String username, String password) {
		
		String queryString = "SELECT ad " +
							 "FROM Advertiser ad " +
							 "WHERE ad.username = ? " +
							 "AND ad.password = ?";
		
		List<Advertiser> advertisers = complexQuery(queryString, new Object[]{username, password});
		
		if(advertisers.size() > 0 && advertisers.size() == 1)
			return advertisers.get(0);
		
		return null;
	}


}
